﻿@model IEnumerable<HelloMinasan.Domain.SongReport>
@{
    string reporttype = ViewData["ReportType"].ToString();
    string Language;
    int commentid = 0;
    string comment = null;
    int NextPageNumber = (int)ViewData["NextPageNumber"];
    int PreviousPageNumber = (int)ViewData["PreviousPageNumber"];
    int TotalPageCount = (int)ViewData["TotalPageCount"];
    int CurrentPageNumber = (int)ViewData["CurrentPageNumber"];
}
@{
    ViewBag.Title = "GetReportAll";
}

<script>
    function AddBadWordsFilter() {
        $("#errorMessage").html("");
        var BadWords = $("#BadWordsFilter").val();
        var Lang = $("#comboboxLanguage22").val();
        if (BadWords.length < 1) {
            $("#errorMessage").html("Can't be less than 1 characters.");
            return;
        }
    $("#reportingDiv").hide();
    $("#loadingIndicatorReportSong").show();
    $.ajax(
        {
            type: "POST",
            url: "/Report/InsertBadWord",
            data: { BadWord: BadWords, lang: Lang },
            success: function (result) {
                if (result.Result) {
                    $("#loadingIndicatorReportSong").hide();
                    $.msgbox(result.Message, { type: "info" });
                }
                else {
                    $.msgbox(result.Message, { type: "error" });
                }
            }
        });
    }

    function DeleteSongReport(pid) {
        if (confirm("Do you want to delete product?")) {
            var data = { 'Id': pid }
            $.post('/Report/Delete', data,
            function (data) {
                if (data == true)
                    location = location.href;
                else
                    alert("Could not delete");
            });
        }
    }

    function gotoSongReportPage(jssongid, jscurrentpage, jspagenumber) {
        $("#loaderIndicator").show();
        $.ajax(
            {
                type: "POST",
                url: "/Report/GetReportAll",
                data: { type: jssongid, number: jscurrentpage, pagenumber: jspagenumber },
                success: function (result) {
                    location = location.href;
                },
                error: function (error) {
                    alert(error);
                }
            });
    }

    function jumpToPageSongReport(pageElement, songId, jspagenumber) {
        var jscurrentpage = $(pageElement).val();
        gotoSongReportPage(songId, jscurrentpage, jspagenumber);
    }
</script>

@*tiêu đề*@
<div class="contentSection">
            <div style="display: table; width: 100%">
                @if (reporttype == "1")
                {
                    <div style="padding-left:40px;">
                    <span class="titleNewFont" style="font-size: 20px; font-weight: normal">Song Report</span>
                    <hr />
                    </div>
                }
                else if (reporttype == "2")
                {
                    <div style="padding-left:40px;">
                    <span class="titleNewFont" style="font-size: 20px; font-weight: normal">Lyric Repor</span>
                    <hr />
                    </div>
                }
                else
                {
                    <div style="padding-left:40px;">
                    <span class="titleNewFont" style="font-size: 20px; font-weight: normal">Comment Report</span>
                    <hr />
                    </div>
                }
            </div>
        </div>
@*nội dung*@
<div class="contentSectionInside" style="margin-bottom: 10px;">
     @if (reporttype == "1")
     {
         <table class="tableSearch" width="100%" cellspacing="0">
        <thead>
            <th></th>
            <th style="width:30px;padding-left:5px;"></th>
            <th>Song name</th>
            <th>Report comment</th>
            <th>Reporter</th>
            <th></th>
        </thead>
        <tbody>
            @if (Model.Any())
            {
                foreach (var item in Model)
                {
                    <tr>
                       <td style= "width: 5%">
                          <a href="#" onclick="DeleteSongReport(@item.ID)" title="Delate">
                              <img src="~/Content/Images/report_delete.png" />
                          </a>
                        </td>
                        <td><img src="@item.Song.Images" width="30" height="40" /></td>
                        <td class="titleNewFont fontbold"><a href="/Song/Songs/@item.Song.Id">@item.Song.SongName</a></td>
                        <td>@item.ReportComment</td>
                        <td><a href="/Account/UserInformation/@item.User.Username"><b>@item.User.Username</b></a></td>
                        <td>
                            <button class="buttonClass">
                                <a href="@Url.Action("SongReport", "Report", new { id = @item.SongID, currentpage = 1 })">
                                    View Detail
                                </a>
                            </button>
                        </td>
                    </tr>
                }
            }
            else
            {
                <tr>
                    <td colspan="5">There is no report</td>
                </tr>
            }
        </tbody>
        </table>
     }
     else if (reporttype == "2")
     {
        <table class="tableSearch" width="100%" cellspacing="0">
        <thead>
            <th></th>
            <th style="width:30px;padding-left:5px;"></th>
            <th>Song name</th>
            <th>Language</th>
            <th>Reporter</th>
            <th></th>
        </thead>
        <tbody>
            @if (Model.Any())
            {
                foreach (var item in Model)
                {
                    Language = item.Song.LyricDetails.Where(x => x.ID == item.LyricID).FirstOrDefault().Language.Name;
                    <tr>
                        <td style= "width: 5%">
                          <a href="#" onclick="DeleteSongReport(@item.ID)" title="Delate">
                              <img src="~/Content/Images/report_delete.png" />
                          </a>
                        </td>
                        <td><img src="@item.Song.Images" width="30" height="40" /></td>
                        <td class="titleNewFont fontbold"><a href="/Song/Songs/@item.Song.Id">@item.Song.SongName</a></td>
                        <td>@Language</td>
                        <td><a href="/Account/UserInformation/@item.User.Username"><b>@item.User.Username</b></a></td>
                        <td>
                            <button class="buttonClass">
                                <a href="@Url.Action("LyricReport", "Report", new { songid = @item.SongID, lyricid = @item.LyricID })">
                                    View Detail
                                </a>
                            </button>
                        </td>
                    </tr>
                }
            }
            else
            {
                <tr>
                    <td colspan="5">There is no report</td>
                </tr>
            }
        </tbody>
</table>
     }
     else
     {
         <table class="tableSearch" width="100%" cellspacing="0">
        <thead>
            <th></th>
            <th style="width:30px;padding-left:5px;"></th>
            <th>Song name</th>
            <th>Comment</th>
            <th>Reporter</th>
            <th></th>
        </thead>
        <tbody>
            @if (Model.Any())
            {
                foreach (var item in Model)
                {
                    var commentItemSelect = item.Song.SongComments.Where(x => x.CommentId == item.CommentID).FirstOrDefault();
                    commentid = commentItemSelect.CommentId;
                    comment = commentItemSelect.CommentContent;
                    <tr>
                        <td style= "width: 5%">
                          <a href="#" onclick="DeleteSongReport(@item.ID)" title="Delate">
                              <img src="~/Content/Images/report_delete.png" />
                          </a>
                        </td>
                        <td><img src="@item.Song.Images" width="30" height="40" /></td>
                        <td class="titleNewFont fontbold"><a href="/Song/Songs/@item.Song.Id">@item.Song.SongName</a></td>
                        <td>@comment</td>
                        <td><a href="/Account/UserInformation/@item.User.Username"><b>@item.User.Username</b></a></td>
                        <td>
                            <button class="buttonClass">
                                <a href="@Url.Action("CommentReport", "Report", new { commentid = @commentid, songid = @item.Song.Id })">
                                    View Detail
                                </a>
                            </button>
                        </td>
                    </tr>
                }
            }
            else
            {
                <tr>
                    <td colspan="5">There is no report</td>
                </tr>
            }
        </tbody>
</table>
     }
</div>
@**@
<br />
<div align="center" style="margin-top: 10px;">
    @if (PreviousPageNumber > 0)
    {
        <a onclick="gotoSongReportPage(@reporttype, 1, 10)" class="buttonClass">First</a>
        <a onclick="gotoSongReportPage(@reporttype, @CurrentPageNumber +1, 10)" class="buttonClass">Back</a>
    }
    <select onchange="jumpToPageSongReport(this, @reporttype, 10)">
        @for (int i = 1; i <= TotalPageCount; i++)
        {
            if (i != CurrentPageNumber)
            { <option value="@i">@i</option> }
            else
            { <option value="@i" selected>@i</option> }
        }
    </select>
    @if (NextPageNumber <= TotalPageCount)
    {
        <a onclick="gotoSongReportPage(@reporttype, @CurrentPageNumber +1, 10)" class="buttonClass">Next</a>
        <a onclick="gotoSongReportPage(@reporttype, @TotalPageCount, 10)" class="buttonClass">Last</a>
    }
</div>
@*phần thêm Bad Words Filte *@
<div id="tooltipSectionFunction">
    <div align="right" style="margin-bottom: 5px;"><b title="Hide" style="cursor: pointer">Add</b></div>
    <div id="tooltipSectionContent" align="center">

        <div class="icon">
            <div class="description">
                <div class="positionTheTooltip">
                    <div class="contentSectionInside" style="width: 350px;">
                        <strong>Add Bad Words Filter</strong>
                    </div>
                    <div class="contentSectionInside" align="left" style="width: 350px;">
                         <span id="comboboxLanguage1">
                             <select id="comboboxLanguage22">
                                 <option value="1">English</option>
                                 <option value="2">Vietnamese</option>
                                 <option value="3">Korea</option>
                                 <option value="4">Indonesia</option>
                                 <option value="5">Chinese</option>
                             </select>
                         </span>
                        <br /><span id="errorMessage"></span>
                        <div>Bad Words Filterent:</div>
                        <input id="BadWordsFilter" type="text" style="width: 320px;" />
                        <div align="right"><a class="linkText" onclick="AddBadWordsFilter()">Add</a></div>
                    </div>
                </div>
            </div>

            <div class="iconShortcut">
                <img style="display:none;margin-top:20px;" id="loadingIndicatorReportSong" src="@Url.Content("~/Content/Images/loader.gif")" />
                <img title="Report this song" src="@Url.Content("~/Content/Images/document-broken.png")" /><br />
                Add Bad Words Filter
            </div>
        </div>
    </div>
</div>
